﻿

using GalaSoft.MvvmLight.Command;
using GalaSoft.MvvmLight.Messaging;
using NicoView.Model.Service;
using NicoView.ViewModel;

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using NicoView.Model.Service.Events;
using NicoView.ViewModel.Message;


namespace NicoView.View
{
    /// <summary>
    /// NicoCommentSimplicityWriteControl.xaml の相互作用ロジック
    /// </summary>
    public partial class NicoViewCommentSimplyWriteControl : UserControl,IDisposable
    {
        public NicoViewCommentSimplyWriteControl()
        {
            InitializeComponent();




            
        }

        public new  NicoViewCommentEditorViewModel DataContext
        {
            get
            {
                return (NicoViewCommentEditorViewModel)base.DataContext;
            }
        }






        private void SimpleEditControl_Loaded(object sender, RoutedEventArgs e)
        {
            if (!DataContext.IsInDesignMode)
            {
                Messenger.Default.Register<NicoViewCommentEditorConnectionMessage>(this, (args) =>
                {




                });

                Messenger.Default.Register<NicoCommentReplyRequestMessage>(this, (ex) =>
                {
                    if (this.EditText.Visibility == Visibility.Visible)
                    {
                        this.EditText.Text = ">>" + ex.Comment.DisplayNo + " ";
                        this.EditText.Focus();
                        this.EditText.CaretIndex = this.EditText.Text.Length;

                    }
                });


                Messenger.Default.Register<NicoViewCommentEditResetMessage>(this, (args) =>
                {

                    this.EditText.Text = "";
                });

                this.DataContext.Loded();
            }
            
        }


        public void Dispose()
        {
            this.DataContext.Dispose();
        }
    }
}
